<script type="text/javascript" src="<?php	 	  echo Yii::app()->request->baseUrl; ?>/js/fancy/source/mootools.js"></script>
<script type="text/javascript" src="<?php	 	  echo Yii::app()->request->baseUrl; ?>/js/fancy/source/Fx.ProgressBar.js"></script>
<script type="text/javascript" src="<?php	 	  echo Yii::app()->request->baseUrl; ?>/js/fancy/source/Swiff.Uploader.js"></script>
<script type="text/javascript" src="<?php	 	  echo Yii::app()->request->baseUrl; ?>/js/fancy/source/FancyUpload3.Attach.js"></script>


<script type="text/javascript">
window.addEvent('domready', function() {

	/**
	 * Uploader instance
	 */
	var up = new FancyUpload3.Attach('demo-list', '#demo-attach, #demo-attach-2', {
		path: '<?php	 	  echo Yii::app()->request->baseUrl; ?>/js/fancy/source/Swiff.Uploader.swf',
		url: '<?php	 	  echo Yii::app()->request->baseUrl; ?>/js/fancy/server/scriptdatakeuangan.php',
		fileSizeMax: 30 * 1024 * 1024,
 
		verbose: true,
 
		onSelectFail: function(files) {
			files.each(function(file) {
				new Element('li', {
					'class': 'file-invalid',
					events: {
						click: function() {
							this.destroy();
						}
					}
				}).adopt(
					new Element('span', {html: file.validationErrorMessage || file.validationError})
				).inject(this.list, 'bottom');
			}, this);	
		},
 
		onFileSuccess: function(file) {
			new Element('input', {type: 'checkbox', 'checked': true, 'id':'checkedfile', 'value':file.name, 'name':'filesUpload[]'}).inject(file.ui.element, 'top');
			file.ui.element.highlight('#e6efc2');
		},
 
		onFileError: function(file) {
			file.ui.cancel.set('html', 'Retry').removeEvents().addEvent('click', function() {
				file.requeue();
				return false;
			});
 
			new Element('span', {
				html: file.errorMessage,
				'class': 'file-error'
			}).inject(file.ui.cancel, 'after');
		},
 
		onFileRequeue: function(file) {
			file.ui.element.getElement('.file-error').destroy();
 
			file.ui.cancel.set('html', 'Cancel').removeEvents().addEvent('click', function() {
				file.remove();
				return false;
			});
 
			this.start();
		}
 
	});
 
});


/**
 * FancyUpload Showcase
 *
 * @license		MIT License
 * @author		Harald Kirschner <mail [at] digitarald [dot] de>
 * @copyright	Authors
 */
 

</script>

<div class="form">

<?php	 	  /** @var BootActiveForm $form */
$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
    'id'=>'horizontalForm',
    'type'=>'horizontal',
	'htmlOptions'=>array('enctype' => 'multipart/form-data'),
)); ?>
 
<fieldset>
 
   <legend>Form Pelaporan SIMAK-BMN</legend>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php	 	  echo $form->errorSummary($model); ?>
	
	<div class="row">
		<?php	 	  echo $form->labelEx($model,'jenis_laporan'); ?>
		<?php	 	  echo CHtml::activeDropDownList($model,'jenis_laporan',CHtml::listData(Master::model()->findAll('tipe_id=10'), 'id', 'nama_master' ), array('prompt'=>'Pilih Jenis Laporan')); ?>
		<?php	 	  echo $form->error($model,'jenis_laporan'); ?>
	</div>

	<div class="row">
		<?php	 	  echo $form->labelEx($model,'judul_laporan'); ?>
		<?php	 	  echo $form->textField($model,'judul_laporan',array('size'=>60,'maxlength'=>255)); ?>
		<?php	 	  echo $form->error($model,'judul_laporan'); ?>
	</div>

	<div class="row">
		<?php	 	  echo $form->labelEx($model,'deskripsi_laporan'); ?>
		<?php	 	  $this->widget('application.extensions.eckeditor.ECKEditor', array(
                'model'=>$model,
                'attribute'=>'deskripsi_laporan',
                )); ?>
		<?php	 	  echo $form->error($model,'deskripsi_laporan'); ?>
	</div>
	
	<?php	 	  
	Yii::app()->clientScript->registerScript('search', "
	$('.pesan-button').click(function(){
		$('.pesan-form').slideToggle();
		return false;
	});
	");
	?>
	<div class="row">
	<?php	 	  echo $form->labelEx($model,'status'); ?>
	<?php	 	  echo $form->dropDownList($model,'status',SWHelper::nextStatuslistData($model)); ?>
	&nbsp;<?php	 	  if(!$model->isNewRecord){ echo CHtml::link('Tambah Pesan','#',array('class'=>'pesan-button')); } ?>
	<?php	 	  echo $form->error($model,'status'); ?>
	</div>
	
	
	<div class="pesan-form" style="display:none">
	<div class="row">
		<?php	 	  echo $form->labelEx($message,'pesan'); ?>
		<?php	 	  echo $form->textArea($message,'pesan',array('rows'=>6, 'cols'=>50)); ?>
		<?php	 	  echo $form->error($message,'pesan'); ?>
	</div>
	</div><!-- search-form -->

	<div class="row">
	<?php	 	  if($model->isNewRecord){ ?>
	<a href="#" id="demo-attach">Attach a file</a>
 	<ul id="demo-list">
	<?php	 	  }else{ ?>
	<a href="#" id="demo-attach">Attach another file</a>
 	<ul id="demo-list">
	<?php	 	  
	$lampirans = explode('#',$model->lampiran);
	$i=0;
	foreach($lampirans as $lampir):
	$lampiran[$i]=$lampir;
	?>
	<li style="background-color: transparent;list-style-type:none;" id="file-1" class="file "><input id="checkedfile" name="filesUpload[]" value="<?php	 	  echo $lampir; ?>" checked="checked" type="checkbox" />&nbsp;<span class="file-title"><?php	 	  echo $lampir; ?></span></li>
	<?php	 	  
	$i++;
	endforeach; 
	?>
	<?php	 	  } ?>
	</ul>
 	<a href="#" id="demo-attach-2" style="display: none;">Attach another file</a>
	</div>

	<div class="form-actions">
    <?php	 	  $this->widget('bootstrap.widgets.BootButton', array('buttonType'=>'submit', 'type'=>'primary', 'icon'=>'ok white', 'label'=>'Submit')); ?>
    <?php	 	  $this->widget('bootstrap.widgets.BootButton', array('buttonType'=>'reset', 'icon'=>'remove', 'label'=>'Reset')); ?>
</div>
</fieldset>
<?php	 	  $this->endWidget(); ?>

</div><!-- form -->